module.exports = class extends think.Controller {
    async __before() {
        if (this.ctx.controller === 'index' && this.ctx.action === 'loginPage' || this.ctx.action === 'login' || this.ctx.action === 'getVcode') { // 如果是admin_index那么久不验证了，直接返回给予登录。
            return;
        }
        const userinfo = await this.session('userinfo');
        const usermenu = await this.session('usermenu');
        const attribute = await this.session('attribute');
        if (!think.isEmpty(userinfo)) {
            this.assign('userinfo', userinfo);
            this.assign('usermenu', usermenu);
            this.assign('attribute', attribute);
            this.assign('controller', this.ctx.controller);
            this.assign('action', this.ctx.action);


        } else {
            return this.redirect('/index/loginPage');
        }
    }
};
